﻿using SqlSugar;
using System.Collections.Generic;
using TiaoTiaoCode.BasicDbCore;

namespace TiaoTiaoCode.AutoUpdate.DbCore.Entities
{
    /// <summary>
    /// 主程序版本信息
    /// </summary>
    [SugarTable("main_program_version", TableDescription = "主程序版本信息")]
    public class MainProgramVersion : BaseEntity
    {
        /// <summary>
        /// SqlSugar需要无参构造函数
        /// </summary>
        public MainProgramVersion()
        {
            ProgramName = string.Empty;
            Catalog = string.Empty;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="programName"></param>
        /// <param name="catalog"></param>
        public MainProgramVersion(string programName, string catalog) => (ProgramName, Catalog) = (programName, catalog);

        /// <summary>
        /// 主程序名
        /// </summary>
        [SugarColumn(ColumnName = "program_name", Length = 200, ColumnDescription = "主程序名")]
        public string? ProgramName { get; set; }

        /// <summary>
        /// 更新程序所在目录
        /// </summary>
        [SugarColumn(ColumnName = "catalog", Length = 1000, ColumnDescription = "更新程序所在目录")]
        public string? Catalog { get; set; }

        /// <summary>
        /// 主版本号
        /// </summary>
        [SugarColumn(ColumnName = "major", ColumnDescription = "主版本号")]
        public int Major { get; set; }

        /// <summary>
        /// 子版本号
        /// </summary>
        [SugarColumn(ColumnName = "version", ColumnDescription = "子版本号")]
        public int Version { get; set; }

        /// <summary>
        /// 修正版本号
        /// </summary>
        [SugarColumn(ColumnName = "minor_number", ColumnDescription = "修正版本号")]
        public int MinorNumber { get; set; }

        /// <summary>
        /// 编译版本号
        /// </summary>
        [SugarColumn(ColumnName = "build_number", ColumnDescription = "编译版本号")]
        public int BuildNumber { get; set; }

        /// <summary>
        /// 用户自定义说明版本号
        /// </summary>
        [SugarColumn(ColumnName = "custom_version", Length = 100, IsNullable = true, ColumnDescription = "用户自定义说明版本号")]
        public string? CustomVersion { get; set; }

        /// <summary>
        /// 是否发版
        /// </summary>
        [SugarColumn(ColumnName = "is_publish", ColumnDescription = "是否发版")]
        public bool IsPublish { get; set; }

        /// <summary>
        /// 版本发布说明
        /// </summary>
        [SugarColumn(ColumnName = "comment", IsNullable = true, ColumnDescription = "发布说明")]
        public string? Comment { get; set; } = default!;

        /// <summary>
        /// 递归文件列表
        /// </summary>
        [Navigate(NavigateType.OneToMany, nameof(ProgramFileDetail.MainProgramVersionId))]
        public List<ProgramFileDetail>? ProgramFileDetails { get; set; } = default!;
    }
}
